home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.07 Jul 90 / Commando Programming ƒ / Rezscripts / RezC.BNDL < prev    next >
Encoding:
Text File  |  1989-08-09  |  2.8 KB  |  126 lines  |  [TEXT/MPS ]

  1. ###    File RezC.BNDL
  2. ###        W. Powell 1988
  3. ###    Command file to generate a bundle resource
  4. ### Uses commando interface
  5.  
  6. Set Exit 0
  7. Set rtyp 'BNDL'
  8. If {#} < 3
  9.     Echo "### {0} Error: Bad arguments, use commando">>Dev:StdErr
  10.     Exit 1
  11. End
  12. # BNDL resource ID
  13. Set rid {1}
  14. Shift 1
  15. # Get optional resource name
  16. If "{1}" == "-nms"
  17.     Set rname "{2}"
  18.     Shift 2
  19. End
  20. # Get signature stuff
  21. Set sig "{1}"
  22. Set sigID {2}
  23. Shift 2
  24. # Option to generate a signature resource as a 'STR '
  25. If "{1}" == "-autogr"
  26.     # Create the signature resource
  27.     Echo "∂nType ∂'{sig}∂' As ∂'STR ∂' ; "
  28.     Echo "Resource ∂'{sig}∂' ({sigID}) ∂{"
  29.     Echo "∂t∂"{2}∂""
  30.     Echo "∂t∂};"
  31.     Shift 2
  32. End
  33. Echo -n "∂nResource ∂'{rtyp}∂' ({rid}"
  34. If ( "{rname}" != "" )
  35.     Echo -n ,∂""{rname}"∂"
  36. End
  37. If ( "{1}" == "-sy" ) ; Echo -n ",SysHeap" ; Shift ; End
  38. If ( "{1}" == "-pu" ) ; Echo -n ",Purgeable" ; Shift ; End
  39. If ( "{1}" == "-lo" ) ; Echo -n ",Locked" ; Shift ; End
  40. If ( "{1}" == "-Pr" ) ; Echo -n ",Protected" ; Shift ; End
  41. If ( "{1}" == "-PL" ) ; Echo -n ",PreLoad" ; Shift ; End
  42. Echo ") ∂{"
  43.  
  44. # Get bundle Resource attributes
  45. Set LoopDone 0
  46. Set BndlCnt 1
  47. Set TypeCnt 0
  48. Set TypeList ""
  49. Set AFile `NewTempFile -q`
  50. WindToRear
  51. Loop # to Get all bundled resources
  52.     Set ArgList ""
  53.     Set ArgList "`RezC.BNDL.more…`"
  54.     If "{ArgList}" == ""
  55.         Set LoopDone 1
  56.     End
  57.     For Arg In `Quote {ArgList}`
  58.         If {BndlCnt} == 1
  59.             # Get Type of next Bundled resource
  60.             Break If "{Arg}" == "-DONE"
  61.             Break If "{Arg}" == ""
  62.             Set rtyp "{Arg}"
  63.             Set BndlCnt `Evaluate {BndlCnt} + 1`
  64.             Continue
  65.         Else If {BndlCnt} == 2
  66.             # Get Local ID of resource
  67.             Set LID {Arg}
  68.             Set BndlCnt `Evaluate {BndlCnt} + 1`
  69.             Continue
  70.         Else If {BndlCnt} == 3
  71.             # Get Actual Resource ID of bundled resource
  72.             Set rid {Arg}
  73.             Set BndlCnt 1
  74.         End
  75.         # Have one bundled resource at this point
  76.         Set NewType 1
  77.         Set OldType 0
  78.         For TheType In `Quote {TypeList}`
  79.             Set OldType `Evaluate {OldType} + 1`
  80.             If "{TheType}" == "{rtyp}"
  81.                 Set NewType 0
  82.                 Break
  83.             End
  84.         End
  85.         If {NewType} != 0
  86.             Set TypeCnt `Evaluate {TypeCnt} + 1 `
  87.             Set TypeList "`Quote {TypeList} "{rtyp}"`"
  88.             Set Bndl{TypeCnt} "{LID},{rid}"
  89.         Else If 0 == 0
  90.             Clear •:∞ "{AFile}"
  91.             Echo "Quote ∂{Bndl{OldType}∂}" >"{AFile}"
  92.             Set Bndl{OldType} "`Execute "{AFile}"` {LID},{rid}"
  93.         End
  94.     End # For
  95.     If "{Arg}" == "-DONE"
  96.         Set LoopDone 1
  97.     End
  98.     Break If {LoopDone}
  99. End
  100. # Write the Rez text
  101. Echo "∂'{sig}∂',∂t∂/* Signature *∂/"
  102. Echo "{sigID},∂t∂t∂/* Signature version *∂/"
  103. Echo ∂{
  104. Set TypeCnt 0
  105. Set Flag 0
  106. For theType In `Quote {TypeList}`
  107.     Set TypeCnt `Evaluate {TypeCnt} + 1`
  108.     If {Flag}
  109.         Echo ";"
  110.     End
  111.     Set Flag 1
  112.     Echo "∂'{theType}∂',∂t∂/* Resource type *∂/∂n∂t∂{"
  113.     Set LocCnt 0
  114.     Echo "Quote ∂{Bndl{TypeCnt}∂}" >"{AFile}"
  115.     For Item In `Execute "{AFile}"`
  116.         If {LocCnt} != 0 
  117.             Echo "," 
  118.         End
  119.         Set LocCnt 1
  120.         Echo -n ∂t"{Item}"
  121.     End
  122.     Echo -n "  }"
  123. End
  124. Echo "∂n∂} ∂};∂n"
  125. Close -n "{AFile}"
  126. Exit 0